package Operation;

import book.Book;
import book.Bookshelf;

import java.util.Scanner;

public class restore implements IoOperation {
    @Override
    public void work(Bookshelf bookshelf){
        System.out.println("正在归还图书，请输入书名：");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();

        int current = bookshelf.getNumber();

        for (int i = 0; i < current; i++){
            Book book = bookshelf.getBooks(i);
            if (book.getName().equals(name)){
                if (book.condition){
                    book.setCondition(false);
                    System.out.println("归还成功！！");
                    return;
                }
            }
        }
        System.out.println("没有你要归还的图书！！");

    }
}
